package com.msh.platform.elm.service.impl;

import com.msh.platform.bizmedia.base.util.Tools;
import com.msh.platform.elm.dao.SmsInfoRepository;
import com.msh.platform.elm.entity.SmsInfo;
import com.msh.platform.elm.service.SmsInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SmsInfoServiceImpl implements SmsInfoService{

    @Autowired
    private SmsInfoRepository smsInfoRepository;
    
    public SmsInfo findFirstByPhone(String phone){
    	return smsInfoRepository.findFirstByPhoneOrderByCreateTimeDesc(phone);
    }
    
    public void saveSms(String phone,Integer userId,String code,String msg,String type){
    	Integer currTime = Tools.getCurrTime();
    	SmsInfo smsInfo = new SmsInfo();
    	smsInfo.setPhone(phone);
    	smsInfo.setUserId(userId);
    	smsInfo.setCode(code);
    	smsInfo.setMsg(msg);
    	smsInfo.setType(type);
    	smsInfo.setCreateTime(currTime);
    	smsInfoRepository.save(smsInfo);
    }

}
